using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    public class PetComponent : TComponent
    {
        public Unit unit;
        protected override void OnDispose()
        {            
        }

        public override void OnCreate(TEntity entity)
        {
            this.unit = entity as Unit;
        }

        public int petID;
        public int petSkill;
        
        public void Initialize(int petID)
        {
            if (petID == 0)
            {
                return;
            }
            this.petID = petID;
            var rPetConfig = TableCenter.pet.Get(petID);
            if (rPetConfig != null)
            {
                this.petSkill = rPetConfig.SkillID;
                var rSkillComp = this.unit.GetComponent<SkillComponent>(ETComponentType.SkillComponent);
                var rPetSkill = SkillFactory.CreateSkill(this.petSkill, 1, this.unit);
                rSkillComp.AddSkill(rPetSkill);
            }
        }
    }
}